﻿using EasyOAuth.Core.OAuth;
using EasyOAuth.Entity.Dto.Request;
using EasyOAuth.Entity.Dto.Result;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EasyOAuth.Service
{
    /// <summary>
    /// 用户
    /// </summary>
    public class UserService
    {
        /// <summary>
        /// 读取配置文件
        /// </summary>
        IConfiguration _configuration;

        /// <summary>
        /// 用户  内置DI
        /// </summary>
        /// <param name="configuration"></param>
        public UserService(IConfiguration configuration)
        {
            _configuration = configuration;
        }


        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public UserLoginResult Login(UserLoginRequest request)
        {

            //_configuration.GetValue<string>("");

            var tokenBuilder = new AccessTokenBuilder();
            var storeData = new Dictionary<string, string>()
            {
                { "ID", "1000"},
                { "EFDID","1"}
            };

            var token = tokenBuilder.Create(storeData);
            return new UserLoginResult
            {
                Token = token,
                Name = "custom to name"
            };
        }
    }
}
